// TS函数类型

// 直接声明函数类型
let say1: (str: string) => string = function(str) { return '' }

// type定义函数类型
type sayType = (str: string) => string
let say2: sayType = function(str) { return '' }

// rest参数
function info(name: string, ...rest: any) {
  console.log(`name: ${name}, rest: ${rest[0]}`)
}
info('张三', 18, '广东省')

// 函数解构
interface Obj { name: string; age: number }
function fn({name, age}: Obj) {
  console.log(`张三, name: ${name}, age: ${age}`)
}
let obj:Obj = { name: "张三", age: 18 }
fn(obj)

export {}